package com.guaoran.micro.services.spring.boot.auto.configuraton.config;

import com.guaoran.micro.services.spring.boot.auto.configuraton.service.ScheduleService;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.util.StringUtils;

/**
 * @author : guaoran
 * @Description 通过 {@link ImportBeanDefinitionRegistrar} 来实现 Enable 注解驱动
 * @date :2019/7/8 21:52
 */
public class ScheduleImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {
    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
        Class clazz = ScheduleService.class;
        RootBeanDefinition beanDefinition = new RootBeanDefinition(clazz);
        String beanName= StringUtils.uncapitalize(clazz.getSimpleName());
        registry.registerBeanDefinition(beanName, beanDefinition);
    }
}
